package br.ufmg.dees.insane.model.geo.halfEdgeDataStructure;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

import br.ufmg.dees.insane.util.IPoint3d;

/**
 * @author Penna, Samuel
 *
 */
public class Vertex implements Serializable{
	
	/**   */
	private static final long serialVersionUID = 1L;
	
	private String id;
	private IPoint3d coords;
	private HashMap<String, Object> values;
     
	private ArrayList<String> keys;
	
    /** The possible keys for the Map. */
    /** The three possible coords of this Vertex.<br>
    *They are stored in this order: <i>x, y, z</i>*/
    public final String COORDS = "COORDS";
    
	/** 
	 * Default Constructor 
	 */
	public Vertex() {
		this.values = new HashMap<String, Object>();
		this.keys = new ArrayList<String>();
	}

	/**
	 * 
	 */
	public Vertex(String index, Object coords) {
		//the Key and The Value
		this.id = index;
        this.values = new HashMap<String, Object>();
		//this.values.put("COORDS", coords);
		this.coords = (IPoint3d)coords;
		this.keys = new ArrayList<String>();
	}
		
	/**
	 * @return Returns the coords.
	 */
	public Object getValue(String key) {
		return this.values.get(key);
	}

	/**
	 * @param coords The coords to set.
	 */
	public void setValue(String key, Object value) {
		if(!this.keys.contains(key)){
			this.keys.add(key);
		}
		this.values.put(key, value);
	}

	/**
	 * @return Returns the id.
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id The id to set.
	 */
	public void setId(String id) {
		this.id = id;
	}
    
      
      /** Returns true if the node has the point values for the key.
       * @param key The key of the point values.
       * @return True if the node has the point values for the key.
       */
      public boolean valuesContainsKey(String key) {
          return this.values.containsKey(key);
      }
      
      
//	******************************************************************************	

	/**
	 * The method return the values.
	 * @return Returns The values.
	 */
	public HashMap<String, Object> getValues() {
		return this.values;
	}

	/**
	 * The method set the field values from the parameter values.
	 * @param values The values to set.
	 */
	public void setValues(HashMap<String, Object> values) {
		this.values = values;
	}

	/**
	 * The method return all Keys of this PointModel.
	 * @return Keys The Keys of all values of this PointModel.
	 */
/*	public String[] getKeys(){
		String[] keys = new String[this.values.size()];
		for(int i=0; i<this.values.size();i++){
			keys[i] = (String)((Set)this.values.keySet()).toArray()[this.values.size()-1-i];
		}
		return keys;
	}
*/
	/**
	 * The method return the coords.
	 * @return Returns The coords.
	 */
	public IPoint3d getCoords() {
		return coords;
	}

	/**
	 * The method set the field coords from the parameter coords.
	 * @param coords The coords to set.
	 */
	public void setCoords(IPoint3d coords) {
		this.coords = coords;
	}

	/**
	 * The method return the keys.
	 * @return Returns The keys.
	 */
	public ArrayList<String> getKeys() {
		return keys;
	}

	/**
	 * The method set the field keys from the parameter keys.
	 * @param keys The keys to set.
	 */
	public void setKeys(ArrayList<String> keys) {
		this.keys = keys;
	}
	
	
//***************************************************************************************
}// end of this class
